import java.util.Arrays;
import java.util.Scanner;

public class MySolution {
    public static int removeElement(int[] nums, int val) {
        int usedsize = nums.length;
        for(int i = 0;i < usedsize;i++){
            if(nums[i]==val){
                for(int j = i;j < usedsize-1;j++){
                    nums[j] =nums[j+1];
                }
                i--;
                usedsize--;
            }
        }
        return usedsize;
    }

    public static void main(String[] args) {
        int[] nums ={0,1,2,2,3,0,4,2};
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数字");
        int val = scanner.nextInt();
        //System.out.println(Arrays.toString(nums));
        int len = MySolution.removeElement(nums,val);
        for (int i = 0; i < len; i++) {
            System.out.print(nums[i]+" ");
        }
    }
}
